package com.ximcontroller.automaters.connector;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.UnknownHostException;

import com.ximcontroller.models.elements.floor.XIMFloor;

public class XIMFloorUDP { 
	
	byte[] buf; 
	DatagramSocket socket;
	DatagramPacket packet; 
	InetAddress address; 
	XIMFloor f;
	

	public XIMFloorUDP(XIMFloor f) { 
		this.f = f; 
		buf = new byte[256];

		try {
			address = InetAddress.getByName("localhost");
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 

	} 
	
	
	
	public void send() throws IOException { 
		//iterable 
		//formato UDP 72 triplets r g b 0..1 0..1 0..1 
		
		
		for (int i = 0; i <= 50; i++) {

			socket = new DatagramSocket(i);
			packet = new DatagramPacket(buf, buf.length, address, i);
			socket.send(packet);

		}

	} 
}




